package com.cv.platform.service.dashboard;

import com.cv.platform.controller.system.dashboard.vo.DashboardRespVO;
import com.cv.platform.controller.system.dashboard.vo.PanelData;
import com.cv.platform.service.favourite.CvVideoFavouriteService;
import com.cv.platform.service.uv.CvDailyUvService;
import com.cv.platform.service.uv.CvVideoTypeUvService;
import com.cv.platform.service.video.CvVideoService;
import com.cv.system.api.user.UserApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 仪表盘业务层接口实现类
 *
 * @author Charles_XDXD
 */
@Service
public class DashboardServiceImpl implements DashboardService {

    @Resource
    private CvVideoService cvVideoService;

    @Resource
    private CvDailyUvService cvDailyUvService;
    
    @Resource
    private CvVideoFavouriteService cvVideoFavouriteService;
    
    @Resource
    private CvVideoTypeUvService cvVideoTypeUvService;
    
    @DubboReference
    private UserApi userApi;

    @Override
    public DashboardRespVO getDashboardInfo() {
        DashboardRespVO resVO = new DashboardRespVO();
        PanelData panelData = new PanelData();
        panelData.setTotalUv(cvDailyUvService.getTotalUv());
        panelData.setTotalPv(cvVideoService.getVideoPV());
        panelData.setTotalCollect(cvVideoFavouriteService.getTotalCollectionCount());
        panelData.setTotalActiveUser(userApi.getActiveUser());
        resVO.setPanelData(panelData);
        resVO.setLastWeekUv(cvDailyUvService.getLastWeekUv());
        resVO.setVideoTypeCountData(cvVideoService.getVideoTypeCountData());
        resVO.setVideoTypeUvData(cvVideoTypeUvService.getVideoTypeUvData());

        return resVO;
    }
    
}
